package com.qianfeng.service.impl;

import com.github.pagehelper.PageHelper;
import com.qianfeng.entity.Role;
import com.qianfeng.mapper.RoleMapper;
import com.qianfeng.service.RoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
@Service
public class RoleServiceImpl implements RoleService {
    @Autowired
    private RoleMapper roleMapper;
    @Transactional
    @Override
    public void addRole(Role role) {
        roleMapper.addRole(role);
    }
    @Transactional
    @Override
    public void updateRole(Role role) {
        roleMapper.updateRole(role);
    }
    @Transactional
    @Override
    public void deleteRole(Integer roleId) {
        roleMapper.deleteRole(roleId);
    }
    @Transactional
    @Override
    public List<Role> getRoleList() {
        return roleMapper.getRoleList();
    }
    @Transactional
    @Override
    public List<Role> getLikeRoleList(String roleName) {
        List<Role> roles = roleMapper.getLikeRoleList(roleName);
        return roles;
    }
    @Transactional
    @Override
    public Role getRoleByRoleId(Integer roleId) {
        Role roleByRoleId = roleMapper.getRoleByRoleId(roleId);
        return roleByRoleId;
    }
    @Transactional
    @Override
    public List<Role> getRolePage(Integer pageNo, Integer pageSize) {
        PageHelper.startPage(pageNo,pageSize);
        List<Role> roleList = roleMapper.getRoleList();
        return roleList;
    }
}
